﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace eDoc.Controls.FTP
{
    public partial class ucListFTP : System.Web.UI.UserControl
    {
        private string partnerCode = BO.Common.PartnerCode;
        private int typeServer = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataTable dt = new DataTable();
            dt = BO.Data.Select_FTP(partnerCode, typeServer);
            repListFTP.DataSource = dt;
            repListFTP.DataBind();
        }

        protected void repListFTP_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id = "";
            if (e.CommandName == "delete")
            {
                id = e.CommandArgument.ToString();
                BO.Data.Delete_FTP(Convert.ToInt32(id));
                BindData();
            }
            else if (e.CommandName == "edit")
            {
                id = e.CommandArgument.ToString();                
                Response.Redirect("/addftp.aspx?id=" + id);
            }
            else if (e.CommandName == "save")
            {
                /*
                HtmlInputHidden t = e.Item.FindControl("firstNameHidden") as HtmlInputHidden;
                Data.Contacts[e.Item.ItemIndex].FirstName = t.Value;
                t = e.Item.FindControl("lastNameHidden") as HtmlInputHidden;
                Data.Contacts[e.Item.ItemIndex].LastName = t.Value;
                EditIndex = -1;
                */
            }
        }

        protected void ddlSelectFTP_SelectedIndexChanged(object sender, EventArgs e)
        {
            typeServer = Convert.ToInt32(ddlSelectFTP.SelectedValue);
            BindData();
        }
    }
}